---
title: Retrieve a provider by ID or primary tax ID
summary: Loads a read-only clsProvider aggregate root by provider ID or primary tax ID.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-21
library: SAIF.Business.View.Provider
reference_type: embedded
operation_id: OP-01
trigger: Caller request (e.g. clsProviderLocation.Provider, clsProvider.GetFormattedTaxID)
---

# Retrieve a provider by ID or primary tax ID

Loads a single `clsProvider` aggregate root, keyed either by its surrogate `ProviderID` or by its 9-digit primary tax ID, and returns it in read-only state for claim/legal consumers.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-01 |
| **Trigger** | Caller request — provider or location navigation, or a direct lookup by tax ID |
| **Inputs** | `IDataPortalInfo`; provider ID (`Decimal`) or primary tax ID (`String`) |
| **Outputs** | `clsProvider` marked `ReadOnly = True` |
| **Primary components** | `clsProvider.GetProvider` |
| **Entry point** | `SAIF.Business.View.Provider/clsProvider.vb:317, 331` |

## Steps

1. Construct `Criteria` with the supplied key; the constructor sets `CriteriaRetrieveType` to `GetByProviderID` or `GetByPrimaryTaxID`.
2. Call `inDataportal.DataAccessLayer.RetrieveObject(criteria)` — the portal invokes `BeforeRetrieve`.
3. `BeforeRetrieve` creates `clsUpdateInfo` from `DataPortalInfo.UserID`, creates a new `IDataRequest` with `SQLStatement = MyCriteria.RetrieveSQL`, and binds either `:PrimaryTaxID` (max length 9) or `:ProviderID` ([SQL-PRV-01](../sql/SQL-PRV-01-provider-by-id.md), [SQL-PRV-01b](../sql/SQL-PRV-01b-provider-by-tax-id.md) against [PROVIDER](../database-tables.md#provider) left-joined to [PROVIDER_TAX_ID](../database-tables.md#provider_tax_id)).
4. Portal executes; `AfterRetrieve` casts `Result` to `clsSAIFDataReader`, calls `Fill()` on the first row (`FormattedPrimaryTaxID`, `ProviderID`, `PrimaryTaxID`, `RegisteredName`, update info), then `MarkOld()`.
   - On failure: if the reader returns no rows, `Fill` is skipped and the object is returned with default values (`ProviderID = 0`).
5. Caller sets `ReadOnly = True` on the returned object ([BR-PRV-004](../business-rules.md#br-prv-004-providers-retrieved-via-factory-methods-are-read-only)). Rule [BR-PRV-001](../business-rules.md#br-prv-001-primary-tax-id-must-be-a-9-digit-number) is registered at construction and evaluated by the framework rule engine on `PrimaryTaxID`.

   > **Origin**: Step 2's portal dispatch (`IDataPortalInfo.DataAccessLayer.RetrieveObject`) and the `clsSAIFDataReader` accessors used in step 4 are implemented in the SAIF BOF Framework package; their internal steps are outside this repository.**

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Caller request]) --> S1[Construct Criteria<br>by ProviderID or PrimaryTaxID]
	S1 --> S2["RetrieveObject via<br>IDataPortalInfo"]
	S2 --> S3["BeforeRetrieve binds<br>parameter"]
	S3 --> S4{Row returned?}
	S4 -->|Yes| S5[AfterRetrieve: Fill, MarkOld]
	S4 -->|No| S6[Default-valued clsProvider<br>ProviderID = 0]
	S5 --> S7[ReadOnly = True]
	S6 --> S7
	S7 --> EndOk([clsProvider returned])
```

## Failure and edge-case behavior

- No matching row: the returned `clsProvider` keeps default field values (`ProviderID = 0`); downstream consumers such as [BR-PLOC-002](../business-rules.md#br-ploc-002-provider-id-must-be-positive) detect this as invalid.
- Primary tax ID failing the 9-digit numeric check breaks rule [BR-PRV-001](../business-rules.md#br-prv-001-primary-tax-id-must-be-a-9-digit-number), setting `IsValid` to false without preventing the object from being returned.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `SAIF.Business.View.Provider/clsProvider.vb`
